Re: [GENERAL] Incrementing a Serial Field

Поиск
Список
Период
Сортировка
От Herouth Maoz
Тема Re: [GENERAL] Incrementing a Serial Field
Дата
Msg-id l03110701b26cc8f67da9@[147.233.159.109]
обсуждение исходный текст
Ответ на Incrementing a Serial Field  (Bob Kruger <bkruger@mindspring.com>)
Список pgsql-general
At 19:07 +0200 on 9/11/98, Bob Kruger wrote:


>
> I do have two questions.  Firstly, I have one table that is updated from a
> text file.  This table also has a serial field that is incremented with
> each new record.  Is there a way to use the copy command to have that field
> automatically updated - e.g. copy table_one from '/data/files/input.txt'
> using delimiters '|' ?
>
> So far, I can get this text file to import just fine when using a table
> without a serial field, but as of yet not had any luck in importing it into
> a table that has a serial field.

Assuming the serial field is defined as a NOT NULL DEFAULT nextval( 'seq'
), the simplest way is to put nulls for that field in the text file. That
is, suppose it is the third field in your table, you write

data for field1|data for field 2|\N|data for field4...

The \N (capital N) stands for null, and will cause Postgres to use the
default value for that field.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma



В списке pgsql-general по дате отправления:

Предыдущее
От: Ulf Mehlig
Дата:
Сообщение: Re: [GENERAL] Case insensitive "contains" search
Следующее
От: "Gene Selkov, Jr."
Дата:
Сообщение: is NULL = NULL true or false?